namespace Ioc.Kernel.LifeStyles
{
    public static class LifeStyleFactory
    {
        /// <summary>
        /// Gets the lifecycle.
        /// </summary>
        /// <param name="lifecycle">The lifecycle.</param>
        /// <param name="componentExpectedLifeTime">The component expected life time.</param>
        /// <returns></returns>
        public static ILifeStyleStrategy GetLifecycle(LifeStyleType lifecycle, int componentExpectedLifeTime)
        {
            switch (lifecycle)
            {
                case LifeStyleType.Singleton:
                    return new SingletonLifeStyleStrategy();

                case LifeStyleType.PerThread:
                    return componentExpectedLifeTime == -1
                               ? new ThreadLifeStyleStrategy()
                               : new ThreadLifeStyleStrategy(componentExpectedLifeTime);

                case LifeStyleType.Transient:
                case LifeStyleType.Default:
                default:
                    return new TransientLifeStyleStrategy();
            }
        }
    }
}